(ns ura.modal
  (:require
   [reagent.core :as r]
   [re-frame.core :as fc]

   [ura.ui :as ui]
   [ura.common :refer [log]]
   [ura.style :refer [attr]]
   )
  )


(defn MyModal [attr & nodes]
  (log "create modal : " attr)
  (let [
        {title :title
         width :width
         isShow :isShow
         confirm :confirm
         key :key
         } attr
        show (r/atom isShow)
        ]
    
    (fc/reg-event-fx
     :modalshow (fn [coeffects event]
                  (let [db (:db coeffects)]
                    ;; TODO
                    )
                  )
     )

    
    (fn [attr & nodes]
      [:div.modal {:class (if @show "is-active") :width width}
       [:div.modal-background {:on-click #(reset! show false)}]
          [:div.modal-content {}
           [:div.box {}
            [:span.is-size-5.has-text-weight-bold  (str title "：")]


            [:div (attr :flex :jc-e)
             [:button.button (attr :mr=5 {:on-click #(reset! show false)}) "取消"]
             [:button.button.is-primary (attr {:on-click #(confirm)}) "确定"]
             ]

            
            ]
           ]
       ]
      )
    )
  )
